package edu.umn.msse.farside.FourH.web;

import edu.umn.msse.farside.FourH.domain.Event;
import edu.umn.msse.farside.FourH.services.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * User: Farside
 * Date: Mar 19, 2009
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/eventDetails")
public class EventDetailsController
{
    private EventService eventService;

    @Autowired
    public void setEventService(EventService eventService)
    {
        this.eventService = eventService;
    }

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
    public String eventDetails(@RequestParam(required=true) Long eventID, HttpServletRequest request)
    {
        Event event = eventService.getEvent(eventID);
        request.setAttribute("event", event);
        request.setAttribute("unfilledPositions", eventService.listUnfilledPositions(event));
        return "eventDetails";
    }
}
